# $Id: PKGBUILD 66459 2012-02-25 02:54:09Z lfleischer $
# Maintainer: Lukas Fleischer <archlinux at cryptocrack dot de>
# Contributor: Eric Belanger <eric@archlinux.org>
# Contributor: dorphell <dorphell@archlinux.org>

pkgname=ngrep
pkgver=1.45
pkgrel=9
pkgdesc='A grep-like utility that allows you to search for network packets on an interface.'
arch=('i686' 'x86_64')
url='http://ngrep.sourceforge.net/'
license=('custom')
depends=('libpcap>=1.0.0' 'pcre')
# Fix build failure when using "-j" (FS#27091).
options=(!makeflags)
source=("http://downloads.sourceforge.net/sourceforge/${pkgname}/${pkgname}-${pkgver}.tar.bz2"
        'ngrep-1.45-fix-ipv6.patch'
        'ngrep-1.45-use-system-pcre.patch')
md5sums=('bc8150331601f3b869549c94866b4f1c'
         '524ee2e0d9ff3c6a262eca836ddf63ed'
         'c546da1e47d3e8bddc7678c81a22a6b7')

build() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  # add patch for broken ipv6 support (FS#27225)
  patch -Np1 -i "$srcdir/ngrep-1.45-fix-ipv6.patch"

  # use system PCRE (FS#27225)
  patch -Np1 -i "$srcdir/ngrep-1.45-use-system-pcre.patch"
  autoreconf

  export EXTRA_INCLUDES=$(pcre-config --cflags)
  export EXTRA_LIBS=$(pcre-config --libs)
  ./configure --prefix=/usr --with-pcap-includes=/usr/include/pcap --enable-ipv6 --enable-pcre
  make
}

package() {
  cd "${srcdir}/${pkgname}-${pkgver}"

  make DESTDIR="${pkgdir}" install
  install -Dm0644 LICENSE.txt "${pkgdir}/usr/share/licenses/${pkgname}/LICENSE.txt"
}
